package cn.wolfcode.luowowo.serach.ulit;

import java.util.Calendar;
import java.util.Date;

public abstract class DateUtil {


    public static long getSendTimeBetween(Date newDate, Date oldDate) {
        // 时间相减取绝对值
        return Math.abs((newDate.getTime()- oldDate.getTime())/1000);
    }

    public static Date getEndDate(Date date) {
        if (date == null) {
            return null;
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR_OF_DAY,23);
        c.set(Calendar.MINUTE,59);
        c.set(Calendar.SECOND,59);
        return c.getTime();
    }

    public static Date getStratDate(Date date) {
        if (date == null) {
            return null;
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.HOUR_OF_DAY,0);
        c.set(Calendar.MINUTE,0);
        c.set(Calendar.SECOND,0);
        return c.getTime();
    }
}
